import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';

class LoginInterceptor extends Interceptor {
   Function loginCall;

  LoginInterceptor({@required this.loginCall});

  @override
  Future onResponse(Response response) {
    if (response.statusCode == 401 &&
        -1 != response.data.toString().indexOf("用户未登录")) {
      ///用户未登陆跳转到登陆页面
      loginCall.call();
    }
    return super.onResponse(response);
  }
}
